#pragma once
#include <iostream>  
#include <conio.h>
#include <windows.h>
#include <fmod.h>
#include <fmod.hpp>
#include <fmod_errors.h>
#include <vector>
#include <string>
#include "AudioClip.h"
#include "PluginManager.h"
#include "AudioUtils.h"

namespace AudioModel{
	struct AudioClip_pos {
		AudioClip * clip;
		FMOD::Channel *channel;
		int *index;
		unsigned int start_offset;
		unsigned int stop_offset;
	};
	class Track
	{
		public:
				~Track(void);
				Track(FMOD::System *);
				Track(const Track &);
				Track & operator=(const Track&);

				void addClip(AudioClip *, unsigned int start_offset,unsigned int stop_offset,unsigned int clip_len,unsigned int track_offset,int clipIndex);
				void rmClip(int clipIndex);
				void play();
				void pause();
				void resume();
				void stop();

				bool isMute();
				bool isSolo();
				bool isRecording();
				bool isPlaying(int clipID);
				void stopChannel(int channelID);

				float getGain();
				float getPan();
				string getLabel();

				void setGain(float g);
				void setPan(float p);
				void setLabel(string label);

				void setMute();
				void setUnMute();
				void setSolo();
				void setUnSolo();
				void setListen(bool listen);
				void setRec(bool rec);

				void setInputChannel(FMOD::ChannelGroup *);
				void setOutputChannel(FMOD::ChannelGroup *);

				FMOD::ChannelGroup * getInputChannel();
				FMOD::ChannelGroup * getOutputChannel();

				FMOD::DSP * getDSP(FMOD_DSP_TYPE type);

				AudioClip_pos *getClips();

				bool isAssign(int clipID);
		private:
				FMOD::System * system;
				FMOD::ChannelGroup *InputChannel;
				FMOD::ChannelGroup *OutputChannel;

				PlugManager::PluginManager *plugManager;

				AudioClip_pos clips[8];

				bool mute;
				bool solo;
				bool record;
				bool listen;

				float gain;
				float pan;
				string label;
	};
}

